import sys

def flatten(tree):
  H = tree[0]
  T = tree[1:]
  string = ''

  if H.count('@')==0: 
    for H2 in H.split('%%%%%'):
      string += '(' + str(H2) + ' '
  if len(T)==1 and isinstance(T[0], str):
    string += T[0] + ')'
  else:
    for subtree in T:
      if not subtree==[]:
        string += flatten(subtree)
    if H.count('@')==0: 
      for H2 in H.split('%%%%%'): string += ')'
  return string


if __name__ == "__main__":
  print flatten(eval(sys.argv[1]))
